$OpenBSD: patch-build_CMakeModules_FindGLIB2_cmake,v 1.1 2015/07/05 12:03:34 zhuk Exp $
Avoid messing up between paths found by pkg-config and CMake itself.
--- build/CMakeModules/FindGLIB2.cmake.orig	Mon Oct  8 00:14:34 2012
+++ build/CMakeModules/FindGLIB2.cmake	Sun Jul  5 05:11:54 2015
@@ -1,12 +1,12 @@
 IF(NOT WIN32)
     INCLUDE(FindPkgConfig)
-    PKG_SEARCH_MODULE( GLIB2 REQUIRED glib-2.0 )
+    PKG_SEARCH_MODULE( PC_GLIB2 REQUIRED glib-2.0 )
 ENDIF()
 
-IF ( WIN32 OR (NOT GLIB2_FOUND AND NOT PKG_CONFIG_FOUND))
     FIND_PATH(GLIB2_GLIB2CONFIG_INCLUDE_PATH
         NAMES glibconfig.h
         PATHS
+          ${PC_GLIB2_LIBDIR}
           /usr/local/lib
           /usr/lib
           /usr/lib64
@@ -17,9 +17,10 @@ IF ( WIN32 OR (NOT GLIB2_FOUND AND NOT PKG_CONFIG_FOUN
     )
 
 
-    FIND_PATH(GLIB2_INCLUDE_DIRS
+    FIND_PATH(GLIB2_INCLUDE_DIR
         NAMES glib.h
         PATHS
+            ${PC_GLIB2_INCLUDEDIR}
             /usr/local/include
             /usr/include
             /opt/local/include
@@ -27,9 +28,10 @@ IF ( WIN32 OR (NOT GLIB2_FOUND AND NOT PKG_CONFIG_FOUN
         PATH_SUFFIXES gtk-2.0 glib-2.0 glib20 
     )
 
-    FIND_LIBRARY(GLIB2_LIBRARIES
+    FIND_LIBRARY(GLIB2_LIBRARY
         NAMES  glib-2.0 glib20 glib
         PATHS  
+            ${PC_GLIB2_LIBDIR}
             /usr/local/lib
             /usr/lib
             /usr/lib64
@@ -37,17 +39,15 @@ IF ( WIN32 OR (NOT GLIB2_FOUND AND NOT PKG_CONFIG_FOUN
             ${GLIB2_BASE_DIR}/lib
     )
     
-    IF(GLIB2_GLIB2CONFIG_INCLUDE_PATH AND GLIB2_INCLUDE_DIRS AND GLIB2_LIBRARIES)
-        SET( GLIB2_INCLUDE_DIRS  ${GLIB2_GLIB2CONFIG_INCLUDE_PATH} ${GLIB2_INCLUDE_DIRS} )
-        SET( GLIB2_LIBRARIES ${GLIB2_LIBRARIES} )
+    IF(GLIB2_GLIB2CONFIG_INCLUDE_PATH AND GLIB2_INCLUDE_DIR AND GLIB2_LIBRARY)
+        SET( GLIB2_INCLUDE_DIRS  ${GLIB2_GLIB2CONFIG_INCLUDE_PATH} ${GLIB2_INCLUDE_DIR} )
+        SET( GLIB2_LIBRARIES ${GLIB2_LIBRARY} )
         SET( GLIB2_FOUND 1)
     ELSE()
         SET( GLIB2_INCLUDE_DIRS )
         SET( GLIB2_LIBRARIES )
         SET( GLIB2_FOUND 0)
     ENDIF()    
-    
-ENDIF ()
 
 #INCLUDE( FindPackageHandleStandardArgs )
 #FIND_PACKAGE_HANDLE_STANDARD_ARGS( GLIB2 DEFAULT_MSG GLIB2_LIBRARIES GLIB2_GLIB2CONFIG_INCLUDE_PATH GLIB2_GLIB2_INCLUDE_PATH )
